package f;

import g.f;
import g.h;
import g.q;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Objects;
import java.util.logging.Logger;
import javax.annotation.Nullable;

/* compiled from: RequestBody */
public abstract class z {

    /* compiled from: RequestBody */
    public class a extends z {
        public final /* synthetic */ t a;
        public final /* synthetic */ h b;

        public a(t tVar, h hVar) {
            this.a = tVar;
            this.b = hVar;
        }

        public long contentLength() throws IOException {
            return (long) this.b.p();
        }

        @Nullable
        public t contentType() {
            return this.a;
        }

        public void writeTo(f fVar) throws IOException {
            fVar.W(this.b);
        }
    }

    /* compiled from: RequestBody */
    public class b extends z {
        public final /* synthetic */ t a;
        public final /* synthetic */ int b;
        public final /* synthetic */ byte[] c;
        public final /* synthetic */ int d;

        public b(t tVar, int i, byte[] bArr, int i2) {
            this.a = tVar;
            this.b = i;
            this.c = bArr;
            this.d = i2;
        }

        public long contentLength() {
            return (long) this.b;
        }

        @Nullable
        public t contentType() {
            return this.a;
        }

        public void writeTo(f fVar) throws IOException {
            fVar.C(this.c, this.d, this.b);
        }
    }

    /* compiled from: RequestBody */
    public class c extends z {
        public final /* synthetic */ t a;
        public final /* synthetic */ File b;

        public c(t tVar, File file) {
            this.a = tVar;
            this.b = file;
        }

        public long contentLength() {
            return this.b.length();
        }

        @Nullable
        public t contentType() {
            return this.a;
        }

        public void writeTo(f fVar) throws IOException {
            Closeable closeable = null;
            try {
                File file = this.b;
                Logger logger = q.a;
                if (file != null) {
                    closeable = q.c(new FileInputStream(file));
                    fVar.G(closeable);
                    return;
                }
                throw new IllegalArgumentException("file == null");
            } finally {
                f.f0.c.f(closeable);
            }
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:9:0x0010  */
    public static f.z create(@javax.annotation.Nullable f.t r2, java.lang.String r3) {
        /*
        r0 = f.f0.c.j;
        if (r2 == 0) goto L_0x0027;
    L_0x0004:
        r0 = r2.c;	 Catch:{ IllegalArgumentException -> 0x000d }
        if (r0 == 0) goto L_0x000d;
    L_0x0008:
        r0 = java.nio.charset.Charset.forName(r0);	 Catch:{ IllegalArgumentException -> 0x000d }
        goto L_0x000e;
    L_0x000d:
        r0 = 0;
    L_0x000e:
        if (r0 != 0) goto L_0x0027;
    L_0x0010:
        r0 = f.f0.c.j;
        r1 = new java.lang.StringBuilder;
        r1.<init>();
        r1.append(r2);
        r2 = "; charset=utf-8";
        r1.append(r2);
        r2 = r1.toString();
        r2 = f.t.b(r2);
    L_0x0027:
        r3 = r3.getBytes(r0);
        r2 = create(r2, r3);
        return r2;
        */
        throw new UnsupportedOperationException("Method not decompiled: f.z.create(f.t, java.lang.String):f.z");
    }

    public long contentLength() throws IOException {
        return -1;
    }

    @Nullable
    public abstract t contentType();

    public abstract void writeTo(f fVar) throws IOException;

    public static z create(@Nullable t tVar, h hVar) {
        return new a(tVar, hVar);
    }

    public static z create(@Nullable t tVar, byte[] bArr) {
        return create(tVar, bArr, 0, bArr.length);
    }

    public static z create(@Nullable t tVar, byte[] bArr, int i, int i2) {
        Objects.requireNonNull(bArr, "content == null");
        f.f0.c.e((long) bArr.length, (long) i, (long) i2);
        return new b(tVar, i2, bArr, i);
    }

    public static z create(@Nullable t tVar, File file) {
        Objects.requireNonNull(file, "file == null");
        return new c(tVar, file);
    }
}
